package com.malljelly.study.controller;

import com.alibaba.fastjson.JSONObject;
import com.malljelly.study.member.vo.back.BackMemberRequestVo;
import com.malljelly.study.service.MemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.*;



/**
 * Created by 骑着蜗牛去旅行 on 2018/8/12.
 */
@Api("会员接口文档")
@RestController  //@Controller+@ResponseBody
@RequestMapping("soa/memberService/")
@Slf4j
public class MemberController extends BaseController {


    @Autowired
    private MemberService memberService;

    /**
     * 新增保存会员
     */
    @ApiOperation(value = "保存会员",response = BackMemberRequestVo.class)
    @PostMapping("saveMember")
    public com.alibaba.fastjson.JSONObject saveMember(@RequestBody BackMemberRequestVo reqVo,@PageableDefault(page = 0, size = 20, sort = "username,asc")Pageable pageable)
    {
        JSONObject result = new JSONObject();
        try {
            memberService.saveMember(reqVo);
            result.put("code", 0);
        } catch (Exception e) {
            e.printStackTrace();
            result.put("code", -1);
            result.put("msg", e.getMessage());
        }
        return result;

    }
}
